﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ExtractFiles
{
    public partial class AddReplaceWithForm : Form
    {
        private MainForm parent;
        private string toRemove;

        public AddReplaceWithForm()
        {
            InitializeComponent();
        }

        public AddReplaceWithForm(MainForm mainForm, string replaceText, string withText)
        {
            InitializeComponent();
            parent = mainForm;
            this.addReplaceTextBox.Text = replaceText;
            this.addWithTextBox.Text = withText;
            toRemove = replaceText + "~" + withText;
        }

        private void confirmAddButton_Click(object sender, EventArgs e)
        {
            parent.ReplaceWithListBox.Items.Remove(toRemove);
            parent.ReplaceWithListBox.Items.Add(this.addReplaceTextBox.Text + "~" + this.addWithTextBox.Text);
            parent.ReplaceWithListBox.SelectedIndex = parent.ReplaceWithListBox.Items.Count - 1;
            this.Close();
        }

        private void cancelAddButton_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
